import axios from "axios"
function getBaseUrl (){
    return process.env.NODE_ENV === "production" ? "/api" : "http://localhost:9000/api"
}

const server = axios.create({
    baseURL: getBaseUrl()
})

export const get = (url,data)=>{
    return new Promise((resolve,reject)=>{
        server.get(url,{params:data}).then(res=>{
            resolve(res.data)
        }).catch(err=>{
            reject(err)
        })
    })
}
export const post = (url,data)=>{
    return new Promise((resolve,reject)=>{
        server.post(url,data).then(res=>{
            resolve(res.data)
        }).catch(err=>{
            reject(err)
        })
    })
}